public class GroupsHelper {
    public String tabUrl; 
    public string wkId{get;set;} 
    public String strjson {get;set;}
    public Boolean isSupport {get;set;}

    public GroupsHelper(ApexPages.StandardController con) { 
       wkId=ApexPages.currentPage().getParameters().get('wkid');
       isSupport=false;
    }

    public PageReference save(){
        List<WorkOrderTeam__c> list_wt=new list<WorkOrderTeam__c>();
        List<Object> inJsonMap = (List<Object>)JSON.deserializeUntyped(strjson);
        for(Object obj : inJsonMap){
            Map<String,Object> objmap=(Map<String,Object>)obj;
            
            if(objmap.get('userid')+''!='')
            {
                WorkOrderTeam__c wt=new WorkOrderTeam__c();
                wt.Name=String.valueOf(objmap.get('username'));
                wt.WorkOrder__c=wkId;
                wt.User__c=Id.valueOf(String.valueOf(objmap.get('userid')));
                wt.IsSupport__c=isSupport;
                list_wt.add(wt);
            }
        }
        try{
            Insert list_wt;
                
        }catch(Exception e){
            ApexPages.addMessage(
            new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage()));
            return null;
        }
        return new PageReference('/'+wkId);
    }

    public PageReference cancel(){
        return new PageReference('/'+wkId);
    }
}